var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(e, t) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(e, t) {
        e.__proto__ = t;
    } || function(e, t) {
        for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
    })(e, t);
}, function(e, t) {
    function n() {
        this.constructor = e;
    }
    o(e, t), e.prototype = null === t ? Object.create(t) : (n.prototype = t.prototype, 
    new n());
}), a = this && this.__decorate || function(e, t, n, r) {
    var o, i = arguments.length, c = i < 3 ? t : null === r ? r = Object.getOwnPropertyDescriptor(t, n) : r;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) c = Reflect.decorate(e, t, n, r); else for (var s = e.length - 1; 0 <= s; s--) (o = e[s]) && (c = (i < 3 ? o(c) : 3 < i ? o(t, n, c) : o(t, n)) || c);
    return 3 < i && c && Object.defineProperty(t, n, c), c;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("LoadManager"), s = e("Global"), c = cc._decorator, l = c.ccclass, d = c.property, u = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.sprite = null, e.label = null, e;
    }
    return i(e, t), e.prototype.onLoad = function() {
        this.sprite.sizeMode = cc.Sprite.SizeMode.CUSTOM;
    }, e.prototype.start = function() {}, e.prototype.init = function(e, t, o) {
        var i = this;
        return console.log("headView url", e, "name", t), this.label && (this.label.string = t ? 5 < t.length ? t.substr(0, 5) + "..." : t : "匿名"), 
        new Promise(function(t, n) {
            e && "" != e.trim() || isNaN(o) ? e ? r.default.getInstance().loadImage({
                url: e
            }).then(function(e) {
                i.sprite && e instanceof cc.Texture2D ? i.sprite.spriteFrame = new cc.SpriteFrame(e) : cc.log(e), 
                t();
            }).catch(function() {
                n();
            }) : n("无效的url") : s.G.personModelList.some(function(e) {
                return e.id == o;
            }) && r.default.getInstance().loadSpriteFrame({
                url: "image/skin/" + o,
                sprite: i.sprite,
                success: function() {
                    t();
                },
                fail: function(e) {
                    n(e);
                }
            });
        });
    }, e.prototype.delayInit = function(e, o, i, c) {
        var a = this;
        return void 0 === o && (o = ""), i ? new Promise(function(t, n) {
            a.scheduleOnce(function() {
                a.label && (a.label.string = o ? 5 < o.length ? o.substr(0, 5) + "..." : o : "匿名"), 
                e && "" != e.trim() || isNaN(c) ? e ? r.default.getInstance().loadImage({
                    url: e
                }).then(function(e) {
                    a.sprite && e instanceof cc.Texture2D ? a.sprite.spriteFrame = new cc.SpriteFrame(e) : cc.log(e), 
                    t();
                }).catch(function() {
                    n();
                }) : n("无效的url") : s.G.personModelList.some(function(e) {
                    return e.id == c;
                }) && r.default.getInstance().loadSpriteFrame({
                    url: "image/skin/" + c,
                    sprite: a.sprite,
                    success: function() {
                        t();
                    },
                    fail: function(e) {
                        n(e);
                    }
                });
            }, i);
        }) : this.init(e, o);
    }, a([ d(cc.Sprite) ], e.prototype, "sprite", void 0), a([ d(cc.Label) ], e.prototype, "label", void 0), 
    a([ l ], e);
}(cc.Component);

n.default = u;